﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mail;
using System.Web.UI;
using System.Web.UI.WebControls;
using WdpaLoginServiceRef;

public partial class Register : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            WdpaLoginService WdpaLoginService1 = new WdpaLoginService();

            AddrCountry.DataSource = WdpaLoginService1.RegCountry();
            AddrCountry.DataBind();
        }

    }

    protected void btnRegister_Click(object sender, EventArgs e)
    {

        WdpaLoginService WdpaLoginService1 = new WdpaLoginService();

        bool RegSuccess = WdpaLoginService1.RegUser(OrgName.Text, UserTitle.Text, FirstName.Text, LastName.Text, Profession.Text,
                                  Phone.Text, Addrline1.Text, Addrline2.Text, AddrTownCity.Text, AddrPCode.Text,
                                  AddrCountry.Text, MobPhone.Text, EmailAddress1.Text, Password1.Text);


        
        if (!RegSuccess)
        {
            //Return dupe email error
            ErrorMessage.Text = "This email address has already been registered.";
            divRegister.Visible = true;
            divRegistrationSuccess.Visible = false;

        }
        else
        {

            divRegister.Visible = false;
            divRegistrationSuccess.Visible = true;
     
        }
    }


    protected void btnFinish_Click(object sender, EventArgs e)
    {
        Response.Redirect("Default.aspx");
    }

}
